
$(function() {
	
	/** error boxes **/
	$.fn.errorStyle = function() {
        var oldErrore = this.html();
        var StyledError = "<div class=\"error ui-state-error ui-corner-all\" style=\"padding: 0 .7em;\">";
        StyledError += "<p><span class=\"ui-icon ui-icon-alert\" style=\"float: left; margin-right: .3em;\">";
        StyledError += "</span>";
        StyledError += oldErrore ;
        StyledError += "</p></div>";
        this.replaceWith(StyledError );
    };
    
    /** info boxes **/
	$.fn.infoStyle = function() {
        var oldInfo = this.html();
        var styledInfo = "<div class=\"infobox ui-state-highlight ui-corner-all\" style=\"padding: 0 .7em;\">";
        styledInfo += "<p><span class=\"ui-icon ui-icon-info\" style=\"float: left; margin-right: .3em;\">";
        styledInfo += "</span>";
        styledInfo += oldInfo ;
        styledInfo += "</p></div>";
        this.replaceWith(styledInfo );
    };
    
    $(".error").errorStyle ();
    $(".infobox").infoStyle ();
    
    /** init all buttons **/
	$(".button").each(function(){
		$(this).button();
	});
	
	
	/** init accordion **/
	$(".accordion").accordion({
		collapsible: true,
		autoHeight: false
	});
	
	/** init date range selectors **/
	$( ".daterange.from" ).datepicker({
		changeMonth: true,
		numberOfMonths: 1,
		dateFormat: "dd.mm.yy",
		changeMonth: true,
		changeYear: true,
		onSelect: function( selectedDate ) {
			$( ".daterange.to" ).datepicker( "option", "minDate", selectedDate );
		}
	});
	$( ".daterange.to" ).datepicker({
		changeMonth: true,
		numberOfMonths: 1,
		dateFormat: "dd.mm.yy",
		changeMonth: true,
		changeYear: true,
		onSelect: function( selectedDate ) {
			$( ".daterange.from" ).datepicker( "option", "maxDate", selectedDate );
		}
	});
	
	
});
